#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time      :2021/7/15 14:57
# @Author    :cjw
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import relationship

from app.db.session import Base


class Item(Base):
    """项目表"""

    __tablename__ = 'items'

    id = Column(Integer, primary_key=True, index=True)
    title = Column(String(255), index=True, comment='标题')
    description = Column(String(255), index=True, comment='描述')
    owner_id = Column(Integer, ForeignKey('users.id'), comment='用户外键id')

    owner = relationship('User', back_populates='items')

    def __repr__(self):
        return f'Item({self.title})'
